//
//  UIButton+ZSAnimation.m
//  Epayment
//
//  Created by safiri on 2018/8/10.
//  Copyright © 2018年 safiri. All rights reserved.
//

#import "UIButton+ZSAnimation.h"

@implementation UIButton (ZSAnimation)

// MARK: 旋转指定度数，一般用于箭头旋转
- (void)rotateBtnImageViewForM_PIWithSelected:(BOOL)isSelected {
    self.selected = isSelected;
    [self rotateBtnImageViewForDegree:M_PI];
}
- (void)rotateBtnImageViewForM_PI {
    self.selected = !self.isSelected;
    [self rotateBtnImageViewForDegree:M_PI];
}
- (void)rotateBtnImageViewForDegree:(double)degree {
    [UIView animateWithDuration:0.5 animations:^{
        self.imageView.transform = CGAffineTransformIdentity;
        if (self.isSelected) {
            CGAffineTransform transform = CGAffineTransformMakeRotation(degree);
            self.imageView.transform = transform;
        }else{
            self.imageView.transform = CGAffineTransformIdentity;
        }
    }];
}

@end
